package win.demonlegion.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.stereotype.Service;
import win.demonlegion.service.inte.RedisLockService;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;

//@Service("redisLockService")
public class RedisLockServiceImpl { //implements RedisLockService {
    private static final Logger logger = LoggerFactory.getLogger(RedisLockService.class);

//    @Autowired
//    private RedisLockRegistry redisLockRegistry;
//
//    @Override
//    public boolean lock(String key) {
//        Lock lock = redisLockRegistry.obtain(key);
//        try {
//            return lock.tryLock(3L, TimeUnit.SECONDS);
//        } catch (Exception e) {
//            logger.error(e.getMessage(), e);
//        }
//        return false;
//    }
//
//    @Override
//    public boolean unlock(String key) {
//        Lock lock = redisLockRegistry.obtain(key);
//        lock.unlock();
//        return true;
//    }
}
